<?php
/*
 * Created on 2013-7-7
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */
 if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class m_admin extends CI_Model {

    function __construct() {
        parent::__construct();
    }

    function edit($id,$admin_name,$admin_pwd,$admin_salt,$admin_email,$admin_phone,$enable){
		$sql = " update `com_admin` set admin_name='{$admin_name}',admin_pwd='{$admin_pwd}',admin_salt='{$admin_salt}',";
		$sql .= " admin_email='{$admin_email}',admin_phone='{$admin_phone}',enable={$enable} where admin_id=".$id;
		//print_r($sql);
    	return $this->db->query($sql);
    }

    function add($admin_name,$admin_pwd,$admin_salt,$admin_email,$admin_phone,$enable){
    	$sql = " insert into `com_admin` (admin_name,admin_pwd,admin_salt,admin_email,admin_phone,enable,add_time) ";
    	$sql .= " values ('$admin_name','$admin_pwd','{$admin_salt}','{$admin_email}','{$admin_phone}',$enable,".time().")";
    	return $this->db->query($sql);
    }

    function get_list($start=0,$len=15) {
        $sql = "select * from `com_admin` order by add_time limit $start,$len";
        $result = $this->db->query($sql)->result_array();
        return $result;
    }

    function get_admin($id){
    	$sql = " select * from `com_admin` where admin_id=".$id;
    	$result = $this->db->query($sql)->row_array();
        return $result;
    }

    function get_admin_count(){
    	return $this->db->count_all('com_admin');
    }

    function delete_list($ids){
    	return $this->db->query('delete from `'.$this->db->dbprefix('com_admin').'`  where  admin_id in('.$ids.')');
    }

    function delete($id){
    	return $this->db->query('delete from `'.$this->db->dbprefix('com_admin').'`  where  admin_id ='.$id);
    }
}
?>
